var app = getApp();
Component({

    properties: {
        top: Number,
        isshow : Boolean,
        type : String,
        index : Number,
        params : Object,
        tempMenu : Object,
    },

    data: {
        showstatus : false,
        Menu : [],
        actindex : 0,
        actcolor : '#000000',
        isIPX : app.globalData.isIPX ? 1 : 0,
        bgcolor : '#ffffff',
        color : '#333333',
    },
    attached() { },
    ready() {
        if( this.data.type == 'admin' ){

            var menu = [{
                url: "/zofui_sales/pages/index/index",
                img: "https://img11.360buyimg.com/ddimg/jfs/t1/66538/19/4014/3269/5d2351f9E53638303/d16ba3ba1f225e55.png",
                actimg: "https://img11.360buyimg.com/ddimg/jfs/t1/66538/19/4014/3269/5d2351f9E53638303/d16ba3ba1f225e55.png",
                name: "首页",
                type: "url",
            }, {
                url: "/zofui_sales/admin/index",
                img: "https://img11.360buyimg.com/ddimg/jfs/t1/35938/15/13798/3947/5d235655Ed3eb0a0b/77d99c2b774d9d57.png",
                actimg: "https://img11.360buyimg.com/ddimg/jfs/t1/42293/22/8848/3257/5d23565bE9a518c91/1b4f6a5371c7bd6b.png",
                name: "功能",
                type: "url",
            }, {
                url: "/zofui_sales/admin/order",
                img: "https://img11.360buyimg.com/ddimg/jfs/t1/80364/29/4062/4417/5d23528dE8e0cfc52/85f00a7d519d81da.png",
                actimg: "https://img11.360buyimg.com/ddimg/jfs/t1/64493/31/4034/3613/5d2352d6Ed530bdf9/1337841fc010375c.png",
                name: "订单",
                type: "url",
            }, {
                url: "/zofui_sales/admin/goods",
                img: "https://img11.360buyimg.com/ddimg/jfs/t1/66682/39/4079/3846/5d2353abE3a420e1a/b062b30113205241.png",
                actimg: "https://img11.360buyimg.com/ddimg/jfs/t1/63518/1/4025/3920/5d2353b0Eedcf527b/f1b0786a2532cdda.png",
                name: this.data.params.fontsty != 33 ? '商品' : '班型',
                type: "url",
            }];

            if( this.data.params.shopid > 0 && this.data.params.shopnav == 1 ){
                menu[0].url = "/zofui_sales/shop/shop?id="+this.data.params.shopid;
            }

            if( this.data.params.amhide == 1 || (this.data.params.adminauth && this.data.params.adminauth.goods*1 == 1) ){
                menu.splice(3,1);
            }
            if( this.data.params.adminauth && this.data.params.adminauth.order*1 == 1 ){
                menu.splice(2,1);
            }

            this.setData({
                Menu : menu,
                actcolor : '#449aff',
                actindex : typeof this.data.index == 'number' ? this.data.index : -1,
            })
        }else if( this.data.type == 'shopinfo' ){
            this.setData({
                Menu : this.data.tempMenu.data,
                actcolor : this.data.tempMenu.actcolor,
                bgcolor : this.data.tempMenu.bgcolor,
                color : this.data.tempMenu.color,
            })
        }

    },
    methods: {
        navigateto : function( e ){
            app.com.navigateto( e );
        },
        redirectto : function( e ){
            app.com.redirectto( e );
        },
        footNavigate(e){
            var url = e.currentTarget.dataset.url;
            wx.switchTab({
              url: url
            })
        },
        shareshop(){
            this.triggerEvent('shareshop',{});
        },
        callphone : function(e){
            app.com.callphone( e );
        },
        toweburl : function(e){
            app.com.toweburl( e );
        },
        location : function( e ){
            app.com.location( e );
        },
    }

})